package com.yunfei.api.taiKangYiLiao;
import com.yunfei.api.cardSend.result.CardSendResultBo;
import com.yunfei.api.taiKangYiLiao.contants.TaiKangYiLiaoApiConstantMessage;
import com.yunfei.api.taiKangYiLiao.enmu.TaiKangResultStatus;
import com.yunfei.api.taiKangYiLiao.param.TaiKangYiLiaoParam;
import com.yunfei.api.taiKangYiLiao.result.TaiKangYiLiaoResultBo;
import com.yunfei.api.user.contants.MingPianZhuanFaContants;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.ResultStatus;
import com.yunfei.mapper.aiiidb.TaiKangYiLiaoMapper;
import com.yunfei.utils.string.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
 * @Description: 泰康医疗
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/api/v2/taikangyiliao")
@Api(value = TaiKangYiLiaoApiConstantMessage.NAMESPACE,tags =  TaiKangYiLiaoApiConstantMessage.NAMESPACE )
public class TaiKangYiLiaoApiController {
    @Autowired
    private Environment env;
    @Autowired
    private TaiKangYiLiaoMapper taiKangYiLiaoMapper;
    @PostMapping(value="/get")
    @ApiOperation(value =TaiKangYiLiaoApiConstantMessage.GET,notes = TaiKangYiLiaoApiConstantMessage.GET,position = 1,response = TaiKangYiLiaoResultBo.class)
    @ResponseBody
    public Object get(TaiKangYiLiaoParam param){
        ResultModel resultModel=new ResultModel();
        Map<String,Object> queryMap=new HashMap<>();
        String mobile=param.getMobile();
        if(StringUtil.isNullOrEmpty(mobile)){
            resultModel.setCode(TaiKangResultStatus.MOBILE_NOTNULL.getCode());
            resultModel.setMessage(TaiKangResultStatus.MOBILE_NOTNULL.getMessage());
            return resultModel;
        }
        queryMap.put("mobile",mobile);
        TaiKangYiLiaoResultBo resultBo=taiKangYiLiaoMapper.get(queryMap);
        resultModel.setCode(ResultStatus.SUCCESS.getCode());
        resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        if(!StringUtil.isNullOrEmpty(resultBo)){
            resultModel.setData(resultBo);
        }else{
            resultModel.setCode(TaiKangResultStatus.NOT_EXSITS.getCode());
            resultModel.setMessage(TaiKangResultStatus.NOT_EXSITS.getMessage());
            resultModel.setData(TaiKangResultStatus.OPER_SUCCESS.getMessage());
        }
        return resultModel;

    }

}
